<?php
/**
 * Description: 品牌活动支持
 * Created by PhpStorm.
 * User: congyukun
 * Date: 2021/3/12
 * Time: 16:20
 */

namespace Biz\model\brandActivity;

use Doraemon\pockets\datebase\BaseDbModel;

class BrandJoinRecord extends BaseDbModel
{
    public const _CONFIG_FILE_ = 'db_store';
    
    public const _CONFIG_SELECT_ = 'db_brand_activity';
    
    public const _DATABASE_ = 'brand_activity';
    
    public const _TABLE_NAME = 'brand_join_record';
    
    public const _SUB_TABLE = false;
    
    public const STATUS_NORMAL = 1;
    
    public const STATUS_STOP = -1;
    
    /**
     * 根据搜索条件获取正常状态投票记录
     * @param $where
     * @param string $filed
     * @return array|bool
     */
    public static function getInfoByWhere($where, $filed = '*')
    {
        $where['r_status'] = self::STATUS_NORMAL;
        return self::select($filed, $where);
    }
    
    /**
     * 获取一条
     * @param $where
     * @param string $filed
     * @return array|mixed
     */
    public static function is_have($where, $filed = 'id'): array
    {
        $where['r_status'] = self::STATUS_NORMAL;
        return self::select($filed, $where);
    }
    
    /**
     * 新增
     * @param array $data
     * @return false|int|mixed|string
     */
    public static function insertData(array $data)
    {
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return self::id();
    }
}